package com.zzf.juc练习;

public class join练习 {

    public static void main(String[] args) {
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                System.out.println(Thread.currentThread().getName()+"---"+i);
            }
        },"T2");
        t2.start();

        new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                System.out.println(Thread.currentThread().getName()+"---"+i);
                if (i==300){
                    System.out.println(Thread.currentThread().getName()+":等待中.......");
                    try {
                        t2.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+":等待结束！！！！！！");
                }
            }
        },"T1").start();
    }

}
